<?php
function viewShiftFunction($userName,$userPassHash){
	if(isset($userName) && isset($userPassHash)){
		$tbl_name = 'employees';
		$sql="SELECT * FROM $tbl_name";

		$link = mysqli_connect("localhost", "root", "","paradigmshift_dev");

		/* check connection */
		if (mysqli_connect_errno()) {
			printf("Connect failed: %s\n", mysqli_connect_error());
			exit();
		}

		$result = $link->query($sql);
		$count = $result->num_rows;

		if($count>0){
			while($row=$result->fetch_assoc()){

				echo "<div class='accordion-group' ><div class='accordion-heading' >
				<div class='row-fluid btn-group'>
				<a style='text-align:left' class='accordion-toggle span8 btn btn-link' 
				data-toggle='collapse' data-parent='#accordion2' href='#collapse".$row['empID']."'"."> " . $row['empLname'] . ", ".$row['empFname']." ". $row['empID'] ." </a>
				<a class='accordion-toggle span2 btn btn-link' href='#shiftModal' role='button' data-toggle='modal' onClick='getEmpID()'>View Shift</a>

				</div></div>
				<div id='collapse".$row['empID']."' "."class='accordion-body collapse'><div class='accordion-inner'>

				<div class='container'>";
				viewShift($row['empID']);

				echo "</div>
				</div>
				</div>
				</div>";
			}
		}
	}
}
function viewShift($data){
	$id = $data;
	$conn = new mysqli('localhost', 'root', '', 'paradigmshift_dev');
	$sql = "SELECT * FROM roledate WHERE empID = $id";

	$result = $conn->query($sql);
  // if the $result contains at least one row
	if ($result->num_rows > 0) {
    // output data of each row from $result
		while($row = $result->fetch_assoc()) {
			echo 'Shift Id: '. $row['dateID']. '<br/>Status: '. $row['shiftStatus'] . '<br /> Start time: '. $row['startTime']. '<br/> End Time: '. $row['endTime'] ;
		}
	}

}
?>